package com.block.api.controller.data;

import com.alibaba.fastjson.JSONObject;
import com.block.common.exception.ApiException;
import com.block.common.model.vo.ResultInfoVO;
import com.block.datapush.form.service.IFormCallBackService;
import com.block.db.entity.FormInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("open/data")
@Validated
public class DataController {

    @Autowired
    IFormCallBackService formCallBackService;

    /**
     * 获取推送信息的手机号
     *
     */
    @RequestMapping(value = "/getMobileInfo", method = {RequestMethod.POST})
    public String specialPush(@RequestAttribute(value = "channelId") String channelId,
                              @RequestAttribute(value = "formInfo") FormInfo formInfo,
                              @RequestAttribute(value = "tranData") JSONObject tranData) throws ApiException {

        String orderNo = tranData.getString("orderNo");
        ResultInfoVO mobileInfo = formCallBackService.getMobileInfo(formInfo, orderNo);

        return JSONObject.toJSONString(mobileInfo);
    }

}
